feat(webapi): saveScreenshot with custom path#5469
Conversation
DavertMik
left a comment
There was a problem hiding this comment.
Can we just split filename path and create folders automatically?
I.saveScreenshot('custom/debug.png') will create output/custom/debug.png
I may get it wrongly as #5404 request may try to save the screenshot to custom path not inside the output folder. |
|
@kobenguyent we can use absolute paths to handle this if provided path is absolute -> save into it so use could use it like this: I dont see a need for another very similar method Just detect global paths and provide such solution in UI I.saveScreenshotToMyPath() inside custom steps file |
|
I see. Initially, I was thinking to reimplement the same function but I thought it may be backwards compatibility so that's why I introduced the new one. |
| module.exports.screenshotOutputFolder = function (fileName) { | ||
| const fileSep = path.sep | ||
|
|
||
| if (fileName.includes(fileSep) && !(fileName.includes(global.output_dir) || fileName.includes(global.codecept_dir))) { |
There was a problem hiding this comment.
Path handling depends on path.sep, so the same input behaves differently on Windows vs POSIX. Can you fix it?
There was a problem hiding this comment.
Can fix word ouput -> output , pls )
| ```js | ||
| I.saveScreenshot('debug.png'); | ||
| I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scrollWidth before taking screenshot | ||
| I.saveScreenshot('customFolder/debug.png') //saves to customFolder/debug.png |
There was a problem hiding this comment.
is misleading with current behavior, it will be output/customFolder/.. . No?
| beforeEach(() => { | ||
| global.output_dir = path.join(global.codecept_dir, 'output') | ||
| // workaround so that we don't need to create an empty custom dir upfront | ||
| global.custom_dir = global.output_dir |
There was a problem hiding this comment.
“custom dir” test currently points custom_dir to output_dir, so it does not truly validate a separate custom path.
Motivation/Description of the PR
Applicable helpers:
Type of change
Checklist:
npm run docs)npm run lint)npm test)